package cn.shop.front.service.impl;

import cn.shop.front.mapper.MediaMapper;
import cn.shop.front.service.MediaService;
import cn.shop.thiredparty.config.OSSConfig;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author : 李一涵
 * @date : Created in 2022/5/18 15:17
 * @description :
 */
@Service
public class MediaServiceImpl implements MediaService {

    @Resource
    private MediaMapper mediaMapper;
    @Resource
    private OSSConfig config;

    @Override
    public List<Map<String, Object>> getNotices(String domain) {
        return mediaMapper.getNotices(domain);
    }

    @Override
    public List<Map<String, Object>> getBanners(String domain) {
        List<Map<String, Object>> list = mediaMapper.getBanners(domain);
        for (Map<String, Object> map : list) {
            if (map.containsKey("picture")) {
                map.put("picture", config.getPrefix() + "/" + map.get("picture"));
            }
        }
        return list;
    }

    @Override
    public String getService(String domain) {
        return mediaMapper.getService(domain);
    }

    @Override
    public Map<String, Object> getNoticeInfo(long id) {
        return mediaMapper.getNoticeInfo(id);
    }
}
